package weixinkeji.dev.dc.buy.order.h.fwy;

import weixinkeji.dev.dc.buy.order.bean.FWYOrder;
import weixinkeji.dev.dc.buy.order.check.FWYOrderCheck;
import sys.wx.ann.hm.H;
import sys.wx.ann.hm.M;
import sys.wx.c.ATR;
import sys.wx.c.components.cv.CV;
import sys.wx.m.db.dao.mysql.Dao;

@H("weixinkeji/dev/dc/buy/order/u")
public class FWYOrderHU {

    @M("/update")
    public static String u(ATR a) {
        //假设FWYOrder对象的ID为ids,此处_id是别名。如果有值就表示要查询跳转。
        return null != a.request.getParameter("_id")
                ? select1(a.request.getParameter("_id"), a)
                : update(a);
    }

    private static String select1(String x, ATR a) {
        a.request.setAttribute("FWYOrder", Dao.selectOneByID(FWYOrder.class, x));
        return "/FWYOrder_U.jsp";//跳转的页面,请根据实际调整
    }
    
    private static String update(ATR a) {
        FWYOrder obj = CV.getObject(FWYOrder.class, a.request, new FWYOrderCheck().doFWYOrder(true));
        if (null == obj) {
            a.out_OK_NO(false, "您提交的数据存在格式问题。请注意数据字符的输入");
            return null;
        }

        a.out_OK_NO(Dao.update(obj));
        return null;
    }
}
